package com.mm.fam.web.controller;

import com.mm.fam.web.base.ResponseModel;
import com.mm.fam.web.service.ContainerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;


/**
 * 容器相关操作
 */

@Api(value="容器操作",description = "容器操作")
@RestController
@RequestMapping(value="/api/container")
public class ContainerController {

    @Autowired
    private ContainerService containerService;

    @GetMapping(value = "/startContainer")
    @ApiOperation(value = "启动账户容器", notes = "启动账户容器")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", required = true, name = "nodeId", value = "节点id", dataType = "int"),
    })
    public ResponseEntity<ResponseModel<Object>> startContainer(@RequestParam(value = "nodeId", required = true) Integer nodeId) {
        return containerService.startContainer(nodeId);
    }

    @GetMapping(value = "/stopContainer")
    @ApiOperation(value = "停止账户容器", notes = "停止账户容器")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", required = true, name = "nodeId", value = "节点id", dataType = "int"),
    })
    public ResponseEntity<ResponseModel<Object>> stopContainer(@RequestParam(value = "nodeId", required = true) Integer nodeId) {
        return containerService.stopContainer(nodeId);
    }

    @GetMapping(value = "/restartContainer")
    @ApiOperation(value = "停止账户容器", notes = "停止账户容器")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", required = true, name = "nodeId", value = "节点id", dataType = "int"),
    })
    public ResponseEntity<ResponseModel<Object>> restartContainer(@RequestParam(value = "nodeId", required = true) Integer nodeId) {
        return containerService.restartContainer(nodeId);
    }
}
